|
|
Dynamic Open SQL WHERE statement
Above program is featuring more complex programming techniques. If in the previous program the codes only use one parameter as Dynamic component, in above program the code must implement some additional features to allow the program runs dynamically.
This program will allow the user to search a particular customer name and one other search condition which will be executed during runtime. This program will then display all the records from table customer SCUSTOM which matches with the conditions defined by the user.
Apart from the usage of Internal Table, the program will also require the usage of Table EDPLINE. This is a special feature in Release 4.6 in its pre-release to allow the construction of string or characters which later will be used within the SELECT statement.
As any other program, the first requirement is variable and table declaration. This program will be using one internal table to keep all the data ITAB_SCUSTOM (Line 3) and one constructible WHERE statement built on a TABLE OF EDPLINE and EDPLINE (Line 4 and 5). EDPLINE will handle all small pieces or components of WHERE statement and the TABLE OF EDPLINE will construct all the pieces or components from EDPLINE into a WHERE string statement which will be used in the WHERE condition in SELECT statement. For the selection screen, the program will allow the user to input a particular name LIKE which means any number of first character(s) which the user want to search on. And also, the program will allow one other optional selection condition from the user (Line 6 and 7). In this example the default is A for the name and ID BETWEEN 1 and 99 as the other condition.
Once the user click Execute or F8 button, the program will start allocating information from the selection screen into EDPLINE which in this example called STR_LINE (Line 8). If the user input an additional condition in the selection screen, the program will also add that information into STR_LINE (Line 9 11).
After all the conditions constructed, the information in STR_LINE will be appended into STR_WHERE as the TABLE OF EDPLINE (Line 13) which will be used in the SELECT statement (Line 14).
Using that dynamically constructed SELECT statement, the program will display the matching records available in table customer SCUSTOM.
|
|
|